﻿/*  
    Copyright (C) <2007-2013>  <Kay Diefenthal>

    DD.UI.MediaCenter is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    DD.UI.MediaCenter is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DD.UI.MediaCenter.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using Microsoft.MediaCenter.UI;

namespace DD.UI.MediaCenter.Views
{
    public class DefaultView : ModelItem
    {
        private Choice _channels;
        private string _informations;

        public event EventHandler ChannelChanged;

        public void NextChannel()
        {
            if (Channels.HasNextValue)
            {
                Channels.NextValue(true);
            }
        }

        protected virtual void OnChannelChanged(object sender, EventArgs args)
        {
            if (ChannelChanged != null)
            {
                ChannelChanged(this, EventArgs.Empty);
            }
        }

        public void PreviousChannel()
        {
            if (Channels.HasPreviousValue)
            {
                Channels.PreviousValue(true);
            }
        }

        public virtual Choice Channels
        {
            get
            {
                return _channels;
            }
            set
            {
                if (_channels != value)
                {
                    if (_channels != null)
                    {
                        _channels.ChosenChanged -= OnChannelChanged;
                    }
                    _channels = value;
                    if (_channels != null)
                    {
                        _channels.ChosenChanged += (OnChannelChanged);
                    }
                    OnChannelChanged(_channels, EventArgs.Empty);
                    FirePropertyChanged("Channels");
                }
            }
        }

        public virtual string Informations
        {
            get
            {
                return _informations;
            }
            set
            {
                if (_informations != value)
                {
                    _informations = value;
                    FirePropertyChanged("Informations");
                }
            }
        }
    }
}

